package com.hxd.mall.network.service;

import com.hxd.mall.module.account.bean.IsRegisterBean;
import com.hxd.mall.module.account.bean.InvitationCodeBean;
import com.hxd.mall.module.account.bean.LoginBean;
import com.hxd.mall.module.account.bean.ServiceFlag;
import com.hxd.mall.module.account.bean.WxLoginSuccessBean;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * API 主要接口- 账户管理
 * Created by qishuai on 2018/7/26.
 */
public interface IAccountFunctionApi {

    /**
     * 手机号是否已经注册
     * @param phoneNum
     */
    @GET("/mall_user/app/v2/users/register")
    Observable<IsRegisterBean> isRegister(@Query("mobile") String phoneNum);

    /**
     * 校验邀请码是否有效
     * @param code
     * /app/v1/codes/{code}/invitation
     * "mall_user/app/v1/invitationCodes"
     */
    @GET("/mall_user/app/v1/codes/{code}/invitation")
    Observable<InvitationCodeBean> invitationCode (@Path("code") String code);

    /**
     * 获取短信验证码
     *
     * @param phoneNum
     * @return
     */
    @GET("/mall_user/app/v1/sms/codes")
    Observable<IsRegisterBean> getVerifyCode(@Query("mobile") String phoneNum);

    /**
     * 登录
     *
     * @return
     */
    @POST("/mall_user/app/v2/users/login")
    Observable<LoginBean> login(@Body RequestBody requestBody);

    /**
     * 注册
     *//*
    @FormUrlEncoded
    @POST("/mall_user/app/v1/users/register")
    Observable<LoginBean> register(@Field("mobile") String mobile ,@Field("verificationCode") String verificationCode,@Field("invitationCode") String invitationCode,@Field("type") Integer type);*/

    /**
     * 注册
     *
     * @return
     */
    @POST("/mall_user/app/v2/users/register")
    Observable<LoginBean> register(@Body RequestBody requestBody);

    /**
     * 获取微信请求标识
     * @return
     */
//    @GET("/mall_user/app/v2/client/channels/wx/code_info")
    @GET("/mall_user/app/v1/authorize/channels/wx/auth_params")
    Observable<ServiceFlag> getFlag();

    /**
     * 传递code值给后端，后端获取用户的微信信息
     * @return
     */
    @POST("/mall_user/app/v1/authorize/channels/wx/auth_login")
    Observable<WxLoginSuccessBean> getUserWXinfo(@Body RequestBody requestBody);

}
